package com.ruoyi.fantasy.task;

import com.ruoyi.fantasy.service.IFantasyUserDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import java.time.LocalDateTime;

@Component("userTask")
@Slf4j
public class UserTask {

    @Autowired
    private IFantasyUserDetailService fantasyUserDetailService;

    public void resumeAllUser() {
        System.out.println("恢复所有玩家的体力值和疲劳值 定时任务开始 : " + LocalDateTime.now().toLocalTime() +
                "\r\n线程 : " + Thread.currentThread().getName());
        StopWatch stopWatch = new StopWatch();
        stopWatch.start("恢复所有玩家的体力值和疲劳值");
        fantasyUserDetailService.batchResumeUser();
        stopWatch.stop();
        log.info("\n恢复所有玩家的体力值和疲劳值语句耗时: " + stopWatch.prettyPrint());
    }
}
